<?php

require_once CAMINO . 'app/plugins/facebook_request/resources/facebook-php-sdk-master/src/facebook.php';

$facebook = new Facebook(array(
    'appId' => '489969611136008',
    'secret' => '8943158bf9e122fd0fe1ed9254e37358',
    'fileUpload' => FALSE
        ));

$user = $facebook->getUser();
$user_profile = NULL;

if ($user) {
    try {
        $user_profile = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        $user = NULL;
        throw $e;
    }
}

if ($user) {
    $logoutURL = $facebook->getLogoutUrl(array(
        'next' => DOMINIO
    ));
} else {
    $statusURL = $facebook->getLoginStatusUrl();
    $loginURL = $facebook->getLoginUrl(array(
        'scope' => 'email',
        'redirect_uri' => DOMINIO
    ));
}
session_write_close(); // ya que facebook abre una session
/*
 * Para depurar
 */
$id_session_facebook = session_id();
$name_session_facebook = session_name();
